* Merges Price and Auction Data

* Select Directory:

clear all
global replication `c(pwd)'
global data "$replication\Data"
global inter "$replication\Dta - Intermediate"
global final "$replication\Dta - Final"
global graphs "$replication\Graphs"

use "$inter\SpainMarketPricePanelOpen.dta"

drop if oprice==.

save "$inter\SpainMarketPricePanelOpen.dta", replace

clear all

use "$inter\AuctionsReady4Merge.dta"

merge m:m dates isin using "$inter\SpainMarketPricePanelOpen.dta"

drop if _merge==2
drop if _merge==1

drop _merge

save "$inter\PricesAuctionsMerged_New.dta", replace

clear all

use "$inter\SpainMarketPricePanelMidClose.dta"

drop if cprice==.

save "$inter\SpainMarketPricePanelMidClose.dta", replace

clear all

use "$inter\PricesAuctionsMerged_New.dta"

merge m:m dates isin using "$inter\SpainMarketPricePanelMidClose.dta"

drop if _merge==2
drop if _merge==1

*checking that cprice and oprice make sense
gen dif=oprice-cprice
**Difference is not zero


save "$inter\PricesAuctionsMerged_New.dta", replace

**Corroborated using  ones with the example in excel
* keep if isin =="es0000012437"




